<template>
  <div class="map">
    <detailIntroduce title="位置周边" view="查看更多周边信息">
      <div class="baidu" ref="mapRef"></div>
    </detailIntroduce>
  </div>
</template>

<script setup>
import detailIntroduce from "@/components/detail-house-introduce/detail-introduce.vue"
import { onMounted, ref } from "vue"

const props = defineProps({
  position: {
    type: Object,
    default: () => ({}),
  },
})

const mapRef = ref()

onMounted(() => {
  const map = new BMapGL.Map(mapRef.value) // 创建地图实例
  const point = new BMapGL.Point(
    props.position.longitude,
    props.position.latitude
  ) // 创建点坐标
  map.centerAndZoom(point, 15) // 初始化地图，设置中心点坐标和地图级别
  const marker = new BMapGL.Marker(point)
  map.addOverlay(marker)
})
</script>

<style lang="less" scoped>
.map {
  padding: 8px;
  border-bottom: 10px solid #eee;
  .baidu {
    height: 250px;
  }
}
</style>
